import request from '@/utils/request'

// 用户登录
// Login = '/sys/login',
export function login(data) {
  return request({
    url: '/authenticate/login',
    method: 'post',
    data
  })
}

// 注册
export function register(data) {
  return request({
    url: '/authenticate/register',
    method: 'post',
    data
  })
}

// 获取验证码
// http://36.139.240.17:8081/gaoyou/sys/randomImage/1629428467008?_t=1753888233906
export function getYzm() {
  return request({
    url: `/sys/randomImage/1629428467008?_t=${new Date().getTime()}`,
    method: 'get',
    // responseType: 'arraybuffer' // 使用arraybuffer而不是blob
  })
}

// 获取历史记录
export function History() {
  return request({
    url: '/api/paper/analyze/history',
    method: 'get',
  })
}

export function analyzeSingle(data) {
  return request({
    url: '/api/paper/analyze_single',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

export function translateSingle(data) {
  return request({
    url: '/api/paper/translate_single',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

export function analyzeMultiple(data) {
  return request({
    url: '/api/paper/analyze_muti',
    method: 'post',
    data: data.params,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    onUploadProgress: data.config.onUploadProgress,
  })
}

// 单个文献查询
export function analyzeStatus(data) {
  return request({
    url: `/api/paper/analyze/status/${data}`,
    method: 'get',
  })
}

// 获取用户信息
export function userCheck(data) {
  return request({
    url: `/api/code/check?userId=${data}`,
    method: 'get'
  })
}

// 用户兑换
export function codeRedeem(data) {
  return request({
    url: `/api/code/redeem?code=${data.code}&userId=${data.userId}`,
    method: 'post'
  })
}

// 保存表头项
export function columnEdit(data) {
  return request({
    url: '/api/paper/analyze/columnOrder',
    method: 'post',
    data
  })
}

// 查看多文件内容
export function columnData(data) {
  return request({
    url: `/api/paper/analyze_muti/status/${data}`,
    method: 'get',
  })
}


// 上传文件积分校验
export function fileCheck(data) {
  return request({
    url: `/api/paper/checkAllowUpload?pages=${data.pages}&modelType=${data.modelType}`,
    method: 'get',
  })
}

// 积分明细
export function myList() {
  return request({
    url: '/api/paper/points/myList',
    method: 'get',
  })
}

// ai问答消息发送
export function chatSend(data) {
  return request({
    url: `/api/chat/send?taskId=${data.taskId}&content=${data.content}&modelType=${data.modelType}`,
    method: 'post',
  })
}

// 获取问答历史
export function chatHistory(id) {
  return request({
    url: `/api/chat/history?taskId=${id}`,
    method: 'get',
  })
}